home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1994 January / PSL Monthly Shareware CD-ROM (Public Software Library) (January 1994).iso / games / dos / misc / monster.com / VOICE.DOC < prev    next >
Encoding:
Text File  |  1990-05-03  |  5.0 KB  |  82 lines

  1.           VOICE DIGITIZATION AND REPRODUCTION ON THE
  2.          IBM PC/XT AND PC/AT BUILT-IN SPEAKER
  3.          --------------------------------------------
  4.  
  5.             Alan D. Jones     July 1988
  6.  
  7.  
  8.     The speaker on the PC and its associated driver circuitry is quite
  9. simple and crude, having been designed primarily for creating single
  10. square-wave tones of various audio frequencies. This speaker is typically
  11. driven by a pair of transistors used as current amplifier which is in turn
  12. driven directly by the output of a TTL gate. This results in only two
  13. possibilities of voltage across the voice coil: 0 volts and 5 volts. Any
  14. sound to be reproduced by this system must be reduced to an approximation
  15. in the form of a stream of constant-amplitude, variable-width rectangular
  16. pulses.
  17.     Examination of a speech waveform on an oscilloscope display quickly
  18. tells us that it is not going to be possible to even remotely mimic this
  19. waveform under the above restrictions. Much of the information contained
  20. in the waveform is in the form of amplitude variations, and this is the
  21. one attribute we cannot reproduce. It is initially tempting to try to
  22. use the technique of the "class D" amplifier to create the waveform, using
  23. high-speed pulse width modulation and depending on the mechanical
  24. characteristics of the speaker and those of the human ear to provide the
  25. missing low-pass filtering. Assuming the sampling rate to be 8 KHz (based
  26. on the Nyquist criterion) and, to conserve memory, assuming the samples
  27. to contain only 4 bits of amplitude information (16 levels), we can see
  28. that data accumulates at a rate of 4k bytes per second, which is certainly
  29. acceptable. The problem comes when we try to play back the sound. Pulses
  30. occur at intervals of 125 microseconds, which doesn't seem too bad, but
  31. since each pulse can have 16 possible widths, it is necessary to time the
  32. pulses with a resolution of well under 8 microseconds. This is only a
  33. couple of instruction times on a 4.77 MHz XT, and even on a fast 80386
  34. it doesn't give the CPU much time between bits to shift bits, read and
  35. increment a pointer, check the pointer to see if it's done yet, etc., not
  36. to mention the difficulty of servicing unrelated interrupts.
  37.     The search for simpler (but still usable) and less CPU-intensive
  38. methods of reproducing speech leads to the question of what information
  39. in the waveform we can discard without an unacceptable loss of
  40. intelligibility. My experiments with running speech signals through
  41. a graphic equalizer revealed that the lower-frequency components, those
  42. which are most visible to the eye on the oscilloscope, are actually of
  43. minimal importance in understanding speech. This is also demonstrated by
  44. the fact that a whisper is just as understandable as normal speech, but
  45. does not make use of vibrating vocal chords, which are the primary source
  46. of low-frequency components in the voice.
  47.     The digitizer circuit consists of two stages of voltage amplification with
  48. some high-pass filtering built into the coupling capacitors, followed by a
  49. differentiator.  The output of the differentiator is fed to a voltage
  50. comparator, thus producing an output which has approximately the following
  51. relationship to the input from the microphone:    If the derivative of the speech
  52. waveform if positive, then the output is logic zero; If the derivative of the
  53. speech waveform is negative, then the output is logic one.  The transition
  54. timing at the output is entirely analog in nature; there is no synchronizing
  55. clock signal anywhere in the circuit.
  56.     If the output of this circuit is connected directly to a speaker, the
  57. resulting sound will still be an understandable version of the input.
  58. Since the output consists of nothing but a digital bit stream, the job
  59. of the computer becomes that of simply recording and accurately reproducing
  60. this bit stream.
  61.     The program operates by reprogramming the 8253 time chip to produce
  62. hardware interrupts at the 16.5 KHz rate. The interrupt service routine then
  63. manipulates the NAND gate driving the speaker based on bits read from the
  64. file. The 16.5 Khz rate was chosen by trial-and-error; this is the audible
  65. "point of diminishing returns", where a further increase in sampling rate
  66. didn't produce enough of an improvement to warrant the increased memory
  67. usage.
  68.     This technique is somewhat limited in its usefulness. It necessitates
  69. the writing of a "badly behaved" program which not only reprograms the timer
  70. chip but also totally hogs the CPU for the duration of the voice output.
  71. Nevertheless, it demonstrates a few interesting things about how humans hear
  72. speech. I first developed this circuit over a year ago as a rebuttal to
  73. someone who said "it couldn't be done". Not only can it be done, it is
  74. actually quite simple. Certainly the circuit could be improved, at the
  75. possible expense of increased complexity. I'm waiting to hear from some of
  76. you. If anyone has questions, especially about my sloppy code, I check
  77. for messages on CIS every three or four days.
  78.  
  79.                             - Alan
  80.  
  81.                               74030,554
  82.